$result->splittingNeeded = true;
} else if ($nbMyParents <= $nbOtherParents) {
$result->indexInLastCommonParent = $myParents[$i - 1]->getIndexOf($this);
+ }
return $result;
}
public function inPre() {
$tree = $this->getParentTree();
- foreach ($tree as $ancestor) {
+ foreach ($tree as &$ancestor) {
if ($ancestor->isPre()) {
return true;
}
function __construct($parent, $qName, /*array*/ $attributes) {
parent::__construct($parent);
$this->qName = strtolower($qName);
- foreach($attributes as $key => $value){
+ foreach($attributes as $key => &$value){
$this->attributes[strtolower($key)] = $value;
}
return $this->openingTag = Xml::openElement($this->qName, $this->attributes);
public function getIndexOf(Node $child) {
// don't trust array_search with objects
- foreach ($this->children as $key => $value){
+ foreach ($this->children as $key => &$value){
if ($value === $child) {
return $key;
}
return $nodes;
}
- foreach ($this->children as $child) {
+ foreach ($this->children as &$child) {
$allDeleted_local = false;
$somethingDeleted_local = false;
$childrenChildren = $child->getMinimalDeletedSet($id, $allDeleted_local, $somethingDeleted_local);
$newThis = new TagNode(null, $this->qName, $this->attributes);
$newThis->whiteBefore = $this->whiteBefore;
$newThis->whiteAfter = $this->whiteAfter;
- foreach ($this->children as $child) {
+ foreach ($this->children as &$child) {
$newChild = $child->copyTree();
$newChild->setParent($newThis);
$newThis->children[] = $newChild;
public function copyTree() {
$newThis = new BodyNode();
- foreach ($this->children as $child) {
+ foreach ($this->children as &$child) {
$newChild = $child->copyTree();
$newChild->setParent($newThis);
$newThis->children[] = $newChild;
public function getMinimalDeletedSet($id, &$allDeleted, &$somethingDeleted) {
$nodes = array();
- foreach ($this->children as $child) {
+ foreach ($this->children as &$child) {
$childrenChildren = $child->getMinimalDeletedSet($id,
$allDeleted, $somethingDeleted);
$nodes = array_merge($nodes, $childrenChildren);
function __construct(TagNode $parent, /*array*/ $attrs) {
if(!array_key_exists('src', $attrs)) {
//wfDebug('Image without a source:');
- //foreach ($attrs as $key => $value) {
+ //foreach ($attrs as $key => &$value) {
//wfDebug("$key = $value");
//}
parent::__construct($parent, '<img></img>');
public function characters($parser, $data) {
$matches = preg_split(self::regex, $data, -1, PREG_SPLIT_DELIM_CAPTURE);
- foreach($matches as $word) {
+ foreach($matches as &$word) {
if (preg_match(self::whitespace, $word) && $this->notInPre) {
$this->endWord();
$this->lastSibling->whiteAfter = true;
private $oldBodyNode;
private $lastModified = array();
-
+
private $newID = 0;
-
+
private $changedID = 0;
private $changedIDUsed = false;
if (count($this->lastModified) > 0) {
$mod->prevMod = $this->lastModified[0];
if (is_null($this->lastModified[0]->nextMod )) {
- foreach ($this->lastModified as $lastMod) {
+ foreach ($this->lastModified as &$lastMod) {
$lastMod->nextMod = $mod;
}
}
if ($nbLastModified > 0) {
$mod->prevMod = $this->lastModified[0];
if (is_null($this->lastModified[0]->nextMod )) {
- foreach ($this->lastModified as $lastMod) {
+ foreach ($this->lastModified as &$lastMod) {
$lastMod->nextMod = $mod;
}
}
if (count($this->lastModified) > 0) {
$mod->prevMod = $this->lastModified[0];
if (is_null($this->lastModified[0]->nextMod )) {
- foreach ($this->lastModified as $lastMod) {
+ foreach ($this->lastModified as &$lastMod) {
$lastMod->nextMod = $mod;
}
}
$currentIndexLeft = 0;
$currentIndexRight = 0;
- foreach ($differences as $d) {
+ foreach ($differences as &$d) {
if ($d->leftstart > $currentIndexLeft) {
$domdiffer->handlePossibleChangedPart($currentIndexLeft, $d->leftstart,
$currentIndexRight, $d->rightstart);
}
$numbers = array($ll, $nll, $rl, $nrl);
$d = 0;
- foreach ($numbers as $number) {
+ foreach ($numbers as &$number) {
while ($number > 3) {
$d += 3;
$number -= 3;
}
private function addRecursive(TagNode $tree) {
- foreach ($tree->children as $child) {
+ foreach ($tree->children as &$child) {
if ($child instanceof TagNode) {
$this->addRecursive($child);
} else if ($child instanceof TextNode) {
class TagToStringFactory {
- private static $containerTags = array('html', 'body', 'p', 'blockquote',
+ private static $containerTags = array('html', 'body', 'p', 'blockquote',
'h1', 'h2', 'h3', 'h4', 'h5', 'pre', 'div', 'ul', 'ol', 'li',
'table', 'tbody', 'tr', 'td', 'th', 'br', 'hr', 'code', 'dl',
'dt', 'dd', 'input', 'form', 'img', 'span', 'a');
-
+
private static $styleTags = array('i', 'b', 'strong', 'em', 'font',
'big', 'del', 'tt', 'sub', 'sup', 'strike');
if (count($attributes) < 1) {
return;
}
-
+
$firstOne = true;
$lastKey = null;
- foreach ($attributes as $key => $attr) {
+ foreach ($attributes as $key => &$attr) {
$lastKey = $key;
if($firstOne) {
$firstOne = false;
$changeStarted = false;
$changeTXT = '';
- foreach ($node->children as $child) {
+ foreach ($node->children as &$child) {
if ($child instanceof TagNode) {
if ($newStarted) {
$handler->endElement('span');
if ($newStarted && ($mod->type != Modification::ADDED || $mod->firstOfID)) {
$handler->endElement('span');
$newStarted = false;
- } else if ($changeStarted && ($mod->type != Modification::CHANGED
+ } else if ($changeStarted && ($mod->type != Modification::CHANGED
|| $mod->changes != $changeTXT || $mod->firstOfID)) {
$handler->endElement('span');
$changeStarted = false;